<?php
App::import('Model', 'Ciede');
$ciespaciente = new Ciede();
//$ciede = $ciespaciente->find('first', array('Ciede.id'=>12325));
//debug($ciede);exit;
?>
<div class="content">
    <div class="grid_container">
    
    <div class="grid_12">
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon blocks_images"></span>
                    <h6>Antecedentes</h6>
                </div>
                <div class="widget_content">
                    <h3>Listado Antecedentes </h3>
                    <table class="display data_tbl">
                        <thead>
                            <tr>
                                <th class="sorting_desc">
                                    Nro consulta
                                </th>
                                <th>
                                    fecha
                                </th>
                                <th>
                                    Motivo de consulta
                                </th>
                                <th>
                                    Diagn&oacute;stico
                                </th>
                                <th>
                                    detalles
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($historial as $h): ?>
                                <tr class="<?php echo fmod($i, 2) ? "gradeA" : "gradeC" ?>">
                                    <td class=" sorting_1">
                                        <?php echo $h['Consultasexterna']['id'] ?>
                                    </td>
                                    <td>
                                        <?php echo $h['Consultasexterna']['fecha'] ?>
                                    </td>
                                    <td>
                                        <?php echo $h['Consultasexterna']['motivoconsulta'] ?>
                                    </td>
                                    <td class="center">
                                        <?php if (!empty($h['CiedesPaciente'])): ?>
                                            <table>
                                                <?php foreach ($h['CiedesPaciente'] as $cie): 
                                                    ?>
                                                    <tr>
                                                        <td>
                                                            <?php
                                                            $ciede = $ciespaciente->find('first', array('conditions'=>array('Ciede.id' => $cie['ciede_id'])));?>
                                                            <?php echo $ciede['Ciede']['cod4'] ?>-<?php echo $ciede['Ciede']['descod4'] ?>
                                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <?php echo $cie['observaciones'] ?>
                                                        </td>
                                                    </tr>
                                                <?php endforeach; ?>
                                            </table>
                                        <?php endif; ?>
                                    </td>
                                    <td class="center">
                                        <span><a class="action-icons c-add" href="<?php echo $this->Html->url(array('controller'=>'Pacientes', 'action'=>'verestadopaciente', $h['Consultasexterna']['id']))?>" title="Detalles">Detalles</a></span>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                   
                </div>
            </div>
                <div class="grid_12">
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon blocks_images"></span>
                    <h6>Antecedente al&eacute;rgicos</h6>
                </div>
                <div class="widget_content">
                    
                    <table class="display data_tbl">
                        <thead>
                            <tr>
                                <th>
                                    Antecedente al&eacute;rgico
                                </th>
                                <th>
                                    detalles
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($historialergias as $h): ?>
                                <tr class="<?php echo fmod($i, 2) ? "gradeX odd" : "gradeX even" ?>">
                                    
                                    <td>
                                        <?php echo $h['Ciede']['cod4'] ?>&nbsp;
                                        <?php echo $h['Ciede']['descod4']?>&nbsp;
                                        <?php echo $h['CiedesPaciente']['observaciones']?>
                                    </td>
                                    
                                    <td class="center">
                                        <span><a class="action-icons c-add" href="<?php echo $this->Html->url(array('controller'=>'Pacientes', 'action'=>'verestadopaciente', $h['Consultasexterna']['id']))?>" title="Detalles">Detalles</a></span>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                   
                </div>
            </div>
        </div>
      
    </div>
</div>
</div>
    